// Tags: PrrsistedSegTree
#include <algorithm>
#include <cstdio>

const int maxP = 1e3 + 5;
int r, c, m;

namespace PartOne {

const int N = 5e5 + 5;
int cnt, rt[N];

struct Node {
  int ls, rs, sum, siz;
} tr[N << 5];

void insert(int &x, int y, int l, int r, int v) {
  tr[x = ++cnt] = tr[y];
  tr[x].siz++, tr[x].sum += v;
  int mid = (l + r) >> 1;
  if (l == r) return;
  if (v <= mid) insert(tr[x].ls, tr[y].ls, l, mid, v);
  else
    insert(tr[x].rs, tr[y].rs, mid + 1, r, v);
}

int query(int x, int y, int l, int r, int v) {
  if (l == r) return (v + l - 1) / l;
  int mid = (l + r) >> 1, k = tr[tr[y].rs].sum - tr[tr[x].rs].sum;
  if (k < v) {
    return query(tr[x].ls, tr[y].ls, l, mid, v - k) + tr[tr[y].rs].siz -
           tr[tr[x].rs].siz;
  } else {
    return query(tr[x].rs, tr[y].rs, mid + 1, r, v);
  }
}

int main() {
  for (int i = 1, p; i <= c; ++i)
    scanf("%d", &p), insert(rt[i], rt[i - 1], 1, maxP, p);
  for (int x1, y1, x2, d, h; m; --m) {
    scanf("%d%d%d%d%d", &x1, &y1, &x2, &d, &h);
    if (tr[rt[d]].sum - tr[rt[y1 - 1]].sum < h) puts("Poor QLW");
    else
      printf("%d\n", query(rt[y1 - 1], rt[d], 1, maxP, h));
  }
  return 0;
}

}  // namespace PartOne

namespace PartTwo {

const int N = 2e2 + 5;
int p[N][N], maxn, sum[N][N][maxP], tot[N][N][maxP];

inline int solve(int x1, int y1, int x2, int d, int k, int (*val)[N][maxP]) {
  return val[x2][d][k] - val[x1 - 1][d][k] - val[x2][y1 - 1][k] +
         val[x1 - 1][y1 - 1][k];
}

int main() {
  maxn = 0;
  for (int i = 1; i <= r; ++i)
    for (int j = 1; j <= c; ++j)
      scanf("%d", &p[i][j]), maxn = std::max(maxn, p[i][j]);
  for (int k = 0; k <= maxn; ++k)
    for (int i = 1; i <= r; ++i) {
      for (int j = 1; j <= c; ++j) {
        sum[i][j][k] = sum[i - 1][j][k] + sum[i][j - 1][k] -
                       sum[i - 1][j - 1][k] + (p[i][j] >= k ? p[i][j] : 0);
        tot[i][j][k] = tot[i - 1][j][k] + tot[i][j - 1][k] -
                       tot[i - 1][j - 1][k] + (p[i][j] >= k ? 1 : 0);
      }
    }
  for (int x1, y1, x2, d, h; m; --m) {
    scanf("%d%d%d%d%d", &x1, &y1, &x2, &d, &h);
    if (solve(x1, y1, x2, d, 0, sum) < h) puts("Poor QLW");
    else {
      int l = 0, r = maxn + 1, mid, ans;
      while (l + 1 < r) {
        mid = (l + r) >> 1;
        if (solve(x1, y1, x2, d, mid, sum) < h) r = mid;
        else
          l = mid, ans = mid;
      }
      printf("%d\n", solve(x1, y1, x2, d, ans, tot) -
                         (solve(x1, y1, x2, d, ans, sum) - h) / ans);
    }
  }
  return 0;
}

}  // namespace PartTwo

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("P2468 [SDOI2010]粟粟的书架.in", "r", stdin);
  freopen("P2468 [SDOI2010]粟粟的书架.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &r, &c, &m);
  return r == 1 ? PartOne::main() : PartTwo::main();
}